from flask_cors import CORS
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler

from app import app
from app.Handler.LotManager import Get10VehicleThread
from app.Handler.MesManager import GetFloorMesVehicleThread
from app.Vendor import Log

CORS(app, resources=r'/*', supports_credentials=True)

if __name__ == '__main__':
    app.debug = False
    app.config['JSON_AS_ASCII'] = False
    # 初始化日志
    Log.config_log()

    get_floor_thread = GetFloorMesVehicleThread()
    get_floor_thread.start()
    get_10_vehicle_thread = Get10VehicleThread()
    get_10_vehicle_thread.start()

    http_serve = WSGIServer(("0.0.0.0", 5200), app, handler_class=WebSocketHandler)
    http_serve.serve_forever()
